﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Scripting.Hosting;

namespace Pahan.McuFusion.Scripting
{
    internal class McuFusionDlrScriptEngine : McuFusionScriptEngine
    {
        internal McuFusionDlrScriptEngine(ScriptEngine engine)
        {
            this.engine = engine;
            this.scope = engine.CreateScope();
        }

        #region Overrides of McuFusionScriptEngine

        public override void ExecuteFile(string path)
        {
            engine.ExecuteFile(path, scope);
        }

        public override object GetVariable(string name)
        {
            return scope.GetVariable(name);
        }

        public override void SetVariable(string name, object value)
        {
            engine.Runtime.Globals.SetVariable(name, value);
            scope.SetVariable(name, value);
        }

        #endregion

        private readonly ScriptEngine engine;

        private readonly ScriptScope scope;

    }
}
